﻿#ifndef CUSTOMLISTVIEW_H
#define CUSTOMLISTVIEW_H

#include <QListView>
#include <QKeyEvent>
#include <QSortFilterProxyModel>
#include <QStringListModel>
#include <QStandardItemModel>
#include <QString>

// myglobalfunctions.h
#ifndef MYGLOBALFUNCTION_H
#define MYGLOBALFUNCTION_H

#include <QString>

// 全局函数声明
QString concatenateStrings(const QString& str1, const QString& str2);

#endif // MYGLOBALFUNCTIONS_H

class CustomListView : public QListView
{
    Q_OBJECT
public:
    CustomListView(QWidget *parent = nullptr);

    void selectFirstRow();
    void setData(const QStringList &data) {
        strListModel->setStringList(data);
    }
    void runListRow(QString command);
    QString getColumnValue(const QString& input, int columnIndex);
    QString getSelectedRowText();
    QString parseCommandAtSymbolWithPath(const QString &path, QString &programPath, QStringList &arguments);
    void parseCommandLineWithSpaceAndParam(const QString &commandLine, QString &programPath, QStringList &arguments);
protected:
    void keyPressEvent(QKeyEvent *event) override;

public slots:
    void itemMovedSlot(int value,QString text);
    void itemMovedPrevSlot(int value,QString text);
    void filterDataSlot(const QStringList &initTextList,const QString &filterText);
signals:
    void sig_input(QString *text);
private:
    void printCurrentItem();
    QStringListModel *strListModel;
    QStringList originalData;
    QStandardItemModel* listViewModel;
};

#endif // CUSTOMLISTVIEW_H
